home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / lib / posix / fpathconf.c < prev    next >
C/C++ Source or Header  |  1990-07-19  |  1KB  |  60 lines

  1. /* POSIX fpathconf (Sec. 5.7.1)         Author: Andy Tanenbaum */
  2.  
  3. #include <lib.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <errno.h>
  7. #include <limits.h>
  8. #include <unistd.h>
  9.  
  10. long fpathconf(fd, name)
  11. int fd;                /* file descriptor being interrogated */
  12. int name;            /* property being inspected */
  13. {
  14. /* POSIX allows some of the values in <limits.h> to be increased at
  15.  * run time.  The pathconf and fpathconf functions allow these values
  16.  * to be checked at run time.  MINIX does not use this facility.
  17.  * The run-time limits are those given in <limits.h>.
  18.  */
  19.  
  20.   struct stat stbuf;
  21.  
  22.   switch(name) {
  23.     case _PC_LINK_MAX:
  24.         /* Fstat the file.  If that fails, return -1. */
  25.         if (fstat(fd, &stbuf) != 0) return(-1L);
  26.         if (S_ISDIR(stbuf.st_mode))
  27.             return(1L);    /* no links to directories */
  28.         else
  29.             return( (long) LINK_MAX);
  30.  
  31.     case _PC_MAX_CANON:
  32.         return( (long) MAX_CANON);
  33.  
  34.     case _PC_MAX_INPUT:
  35.         return( (long) MAX_INPUT);
  36.  
  37.     case _PC_NAME_MAX:
  38.         return( (long) NAME_MAX);
  39.  
  40.     case _PC_PATH_MAX:
  41.         return( (long) PATH_MAX);
  42.  
  43.     case _PC_PIPE_BUF:
  44.         return( (long) PIPE_BUF);
  45.  
  46.     case _PC_CHOWN_RESTRICTED:
  47.         return( (long) 1);    /* MINIX defines CHOWN_RESTRICTED */
  48.  
  49.     case _PC_NO_TRUNC:        /* MINIX does not define NO_TRUNC */
  50.         return( (long) 0);
  51.  
  52.     case _PC_VDISABLE:        /* MINIX defines VDISABLE */
  53.         return( (long) _POSIX_VDISABLE);
  54.  
  55.     default:
  56.         errno = EINVAL;
  57.         return(-1L);
  58.   }
  59. }
  60.